<?php
defined('_JEXEC') or die('Restricted access');
JToolBarHelper::title(JText::_('COM_JHTRAQ_TICKET_SETTINGS'), 'generic.png');
//JToolBarHelper::preferences('com_jhtraq');
?>

<div id="types" style="float:left;width:45%;padding:10px;">
<fieldset class="adminform">
<legend><?php echo JText::_('COM_JHTRAQ_TICKET_TYPES'); ?></legend>
<form action="index.php" method="post">
<input type="hidden" name="option" value="com_jhtraq" />
<input type="hidden" name="view" value="tickets" />
<input type="hidden" name="task" value="saveTypes" />
	<table class="adminlist" cellpadding="1">
		<thead>
			<tr>
				<th width="40%" class="title">
					<?php echo JText::_('COM_JHTRAQ_NAME'); ?>
				</th>
				<th width="40%" class="title">
				<?php echo JText::_('COM_JHTRAQ_BULLET'); ?>
				</th>
				<th>
				</th>
			</tr>
		</thead>
		<tbody>
			<?php 
			$r = 0;
			foreach($this->types as $type)
			{
				?>
				<tr class="row<?php echo $r;?>">
				<td><input type="text" name="type[<?php echo $type['id']?>][name]" value="<?php echo $type['name']?>" /></td>
				<td><input type="text" name="type[<?php echo $type['id']?>][bullet]" value="<?php echo $type['bullet']?>" /></td>
					<td align="right">
					<input type="button" value="<?php echo JText::_('COM_JHTRAQ_DELETE')?>" onclick="if(confirm('<?php echo JText::_('COM_JHTRAQ_ARE_YOU_SURE')?>')) { window.location = 'index.php?option=com_jhtraq&view=tickets&task=deleteType&type=<?php echo $type['id']?>'; }" />
					</td>
				</tr>
			<?php 
			$r = 1-$r;
			} ?>
				<tr>
					<td>
						<input type="text" name="name" value="" /><br />
						<small><?php echo JText::_('COM_JHTRAQ_ENTER_NEW_TYPE');?></small>
					</td>
					<td colspan="2"><input type="text" name="bullet" value="" /></td>
				</tr>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="3" align="right"><input type="submit" value="<?php echo JText::_('COM_JHTRAQ_UPDATE')?>" /></td>
			</tr>
		</tfoot>
	</table>
	</form>
</fieldset>
</div>
<div id="statuses" style="float:left;width:45%;padding:10px;">
<fieldset class="adminform">
<legend><?php echo JText::_('COM_JHTRAQ_TICKET_STATUS'); ?></legend>
<form action="index.php" method="post">
<input type="hidden" name="option" value="com_jhtraq" />
<input type="hidden" name="view" value="tickets" />
<input type="hidden" name="task" value="saveStatuses" />
<table class="adminlist" cellpadding="1">
		<thead>
			<tr>
				<th width="40%" class="title">
					<?php echo JText::_('COM_JHTRAQ_NAME'); ?>
				</th>
				<th width="40%" class="title">
				<?php echo JText::_( 'COM_JHTRAQ_TYPE' ); ?>
				</th>
				<th>
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
		$r = 0;
		foreach($this->statuses as $status) { ?>
				<tr class="row<?php echo $r;?>">
				<td><input type="text" name="statuses[<?php echo $status['id']?>][name]" value="<?php echo $status['name']?>" /></td>
					<td>
					<select name="statuses[<?php echo $status['id']?>][status]">
					<option value="1" <?php  if($status['status']) echo ' selected="selected"';?>><?php echo JText::_('COM_JHTRAQ_OPEN')?></option>
					<option value="0" <?php  if(!$status['status']) echo ' selected="selected"';?>><?php echo JText::_('COM_JHTRAQ_CLOSED')?></option>
						</select>
					</td>
					<td align="right">
						<input type="button" value="<?php echo JText::_('COM_JHTRAQ_DELETE')?>" onclick="if(confirm('<?php echo JText::_('COM_JHTRAQ_ARE_YOU_SURE')?>')) { window.location = 'index.php?option=com_jhtraq&view=tickets&task=deleteStatus&status=<?php echo $status['id']?>'; }" />
					</td>
				</tr>
				<?php
				$r = 1 -$r;
				} ?>
				<tr>
					<td>
						<input type="text" name="name" value="" /><br />
						<small><?php echo JText::_('COM_JHTRAQ_ENTER_NEW_STATUS')?></small>
					</td>
					<td colspan="2">
						<select name="status">
							<option value="1"><?php echo JText::_('COM_JHTRAQ_OPEN')?></option>
							<option value="0"><?php echo JText::_('COM_JHTRAQ_CLOSED')?></option>
						</select>
					</td>
				</tr>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="3" align="right"><input type="submit" value="<?php echo JText::_('COM_JHTRAQ_UPDATE')?>" /></td>
			</tr>
		</tfoot>
	</table>
	</form>
</fieldset>
</div>
<div style="clear:left;"></div>
<div id="priorities" style="float:left;width:45%;padding:10px;">
<fieldset class="adminform">
<legend><?php echo JText::_( 'COM_JHTRAQ_TICKET_PRIORITIES' ); ?></legend>
<form action="index.php" method="post">
<input type="hidden" name="option" value="com_jhtraq" />
<input type="hidden" name="view" value="tickets" />
<input type="hidden" name="task" value="savePriorities" />
<table class="adminlist" cellpadding="1">
		<thead>
			<tr>
				<th width="80%" class="title">
					<?php echo JText::_( 'COM_JHTRAQ_NAME' ); ?>
				</th>
				<th width="20%" class="title">
					
				</th>
			</tr>
		</thead>
		<tbody>
		<?php
		$r = 0;
		foreach($this->priorities as $priority) { ?>
		<tr class="row<?php echo $r;?>">
		<td><input type="text" name="priority[<?php echo $priority['id']?>]" value="<?php echo $priority['name']?>" /></td>
		<td align="right">
		<input type="button" value="<?php echo JText::_('COM_JHTRAQ_DELETE')?>" onclick="if(confirm('<?php echo JText::_('COM_JHTRAQ_ARE_YOU_SURE')?>')) { window.location = 'index.php?option=com_jhtraq&view=tickets&task=deletePriority&priority=<?php echo $priority['id']?>'; }" />
		</td>
		</tr>
		<?php 
		$r = 1-$r;
		} ?>
		<tr>
		<td colspan="2">
		<input type="text" name="name" value="" /><br />
		<small><?php echo JText::_('COM_JHTRAQ_ENTER_NEW_PRIORITY')?></small>
		</td>
		</tr>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="2" align="right"><input type="submit" value="<?php echo JText::_('COM_JHTRAQ_UPDATE')?>" /></td>
			</tr>
		</tfoot>
	</table>
	</form>
</fieldset>
</div>
<div id="severities" style="float:left;width:45%;padding:10px;">
<fieldset class="adminform">
<legend><?php echo JText::_( 'COM_JHTRAQ_TICKET_SEVERITIES' ); ?></legend>
<form action="index.php" method="post">
<input type="hidden" name="option" value="com_jhtraq" />
<input type="hidden" name="view" value="tickets" />
<input type="hidden" name="task" value="saveSeverities" />
<table class="adminlist" cellpadding="1">
		<thead>
			<tr>
				<th width="80%" class="title">
					<?php echo JText::_( 'COM_JHTRAQ_NAME' ); ?>
				</th>
				<th width="20%" class="title">
				</th>
			</tr>
		</thead>
		
		<tbody>
		<?php
		$r = 0;
		foreach($this->severities as $severity) { ?>
		<tr class="row<?php echo $r;?>">
		<td><input type="text" name="severity[<?php echo $severity['id']?>]" value="<?php echo $severity['name']?>" /></td>
		<td align="right">
		<input type="button" value="<?php echo JText::_('COM_JHTRAQ_DELETE')?>" onclick="if(confirm('<?php echo JText::_('COM_JHTRAQ_ARE_YOU_SURE')?>')) { window.location = 'index.php?option=com_jhtraq&view=tickets&task=deleteSeverity&severity=<?php echo $severity['id']?>'; }" />
		</td>
		</tr>
		<?php 
		$r = 1-$r;
		} ?>
		<tr>
		<td colspan="2">
		<input type="text" name="name" value="" /><br />
		<small><?php echo JText::_('COM_JHTRAQ_ENTER_NEW_SEVERITY')?></small>
		</td>
		</tr>
		</tbody>
		<tfoot>
			<tr>
				<td colspan="2" align="right"><input type="submit" value="<?php echo JText::_('COM_JHTRAQ_UPDATE')?>" /></td>
			</tr>
		</tfoot>
	</table>
	</form>
</fieldset>
</div>